﻿@using Jhong.FunMVC.Razor
@{
    var model = @ViewData["model"] as Jhong.FunMVCBlog.Core.Entity.Category;
}
<style>
    .col-xs-12 {
        margin-top: 5px !important;
        padding-left: 5px !important;
    }

        .col-xs-12 h3 {
            margin-top: 5px !important;
        }

    .col-xs-2 {
        padding-right: 0px !important;
        padding-left: 0px !important;
        margin-left: 5px !important;
    }

    .form-group {
        margin-right: 0px !important;
        margin-left:7px !important
    }
</style>

<div class="col-xs-12">
    <h3 class="page-header">编辑分类</h3>
</div>
<div>
    <form class="form-horizontal">
        <div class="form-group form-group-sm">
            <label class="col-xs-2 control-label" for="formGroupInputSmall">名称:</label>
            <div class="col-xs-9">
                @RazorHTMLHelper.HTML.TextBox("Name", model.Name)
                @RazorHTMLHelper.HTML.Hidden("ID", model.ID)
                @RazorHTMLHelper.HTML.Hidden("CreateTime", model.CreateTime)
            </div>
        </div>
        <div class="form-group form-group-sm">
            <label class="col-xs-2 control-label" for="formGroupInputSmall">名称:</label>
            <div class="col-xs-9">
                @RazorHTMLHelper.HTML.RadioButton("IsShow", "1", model.IsShow == Jhong.FunMVCBlog.Core.Enum.ShowStatus.Show) 显示
                @RazorHTMLHelper.HTML.RadioButton("IsShow", "0", model.IsShow != Jhong.FunMVCBlog.Core.Enum.ShowStatus.Show) 隐藏
            </div>
        </div>
        <h5 id="saveErr" style="color:red;margin-left:15px;"></h5>
        <div class="form-group form-group-sm" style="margin:0 0 0 0;padding:10px 55px 0 0;">
            <button type="button" id="sub" class="btn btn-primary btn-sm" style="float:right;">保存</button>
        </div>
    </form>
</div>
<script type="text/javascript">
    (function ($) {
        $("#sub").click(function () {
            if ($("#Name").val().length == 0) {
                $("#saveErr").text("名称不能为空");
                return false;
            }
            var data = $("form").serialize();
            $.post("/Category/EditCategory?" + Math.random(), data, function (res) {
                if (res.IsSuccess) {
                    $("#tmpData").val(res.Msg);
                    $("#cboxClose").trigger("click");
                } else {
                    $("#saveErr").text("保存失败");
                }
                return false;
            });
            return false;
        });
    }(jQuery));
</script>